<template>
	<view class="">
		<image :src="data.item.pic" mode=""></image>
		{{data.item}}
		<!-- pinia:{{Test.current}}--{{Test.name}} -->
	</view>
</template>

<script setup lang="ts">
	import {onLoad, onLaunch, onShow, onHide } from "@dcloudio/uni-app";
	// import {inject} from 'vue' 
	import {useTestStore} from '../../store/index';
	import {storeToRefs} from 'pinia';  // 使pinia有响应
	import {reactive,toRaw} from 'vue';
	const Test = useTestStore()
	let data = reactive({
		item:{}
	});
	// const { current , name} = storeToRefs(Test)
	onLoad((options)=>{
		getItemById(options.id);
	});
	
	const getItemById = (id) => {

		const items = toRaw(Test.ablum)
		for(var i = 0 ; i < items.length ; i ++){
			if(items[i].id == id){   // 不能直接使用 === 是因为 id 不是 number 类型的数据 
				data.item = items[i];
				break;
			}
		}
	}

</script>

<style scoped>
</style>
